package string_test;

/*
public class StringCompare {
    public static void main(String[] args) {

//        String str1 = "abc";
//        String str2 = "aBc";
//        System.out.println(str1.compareTo(str2));
//
//        System.out.println("A".compareTo("a")); // -32
//        System.out.println("a".compareTo("A")); // 32
//        System.out.println("A".compareTo("A")); // 0
//        System.out.println("AB".compareTo("AC")); // -1
//        System.out.println("王".compareTo("李"));//3133

//        char[] ch = new char[]{'a','b','c'};
//        String str = new String(ch);
//        System.out.println(str);

        String str = "hello";
        char[] data = str.toCharArray();
        System.out.println(data[2]);
    }


}

 */

//判断其是否全部由数字所组成
public class StringCompare {
    public static void main(String[] args) {

        String str1 = "123456a";
        String str2 = "123456";
        System.out.println( isNumber(str1) );
        System.out.println( isNumber(str2) );
    }
    public static boolean isNumber(String str){
        //先把字符串转全部转换为数组
        char[] data = str.toCharArray();
        for (char x :
             data) {

//            if(x < '0' || x > '9'){
//                return false;
//            }
             if(!Character.isDigit(x)){
                 return false;
             }
        }
        return true;
        
    }
}